package de.bazinga.rotw.network.message;

import com.captiveimagination.jgn.message.Message;
import com.captiveimagination.jgn.message.type.CertifiedMessage;
import com.captiveimagination.jgn.message.type.PlayerMessage;
import com.captiveimagination.jgn.message.type.TimestampedMessage;

import de.bazinga.rotw.game.RotwGameState;
import de.bazinga.rotw.map.MapList;

public class MapMessage extends Message implements CertifiedMessage, PlayerMessage, TimestampedMessage, GameMessage {	
	private String mapName = "";

	public String getMapName() {
		return mapName;
	}

	public void setMapName(String mapName) {
		this.mapName = mapName;
	}

	
	
	public void handleMessage(RotwGameState game, Message msg, boolean server) {
		if(!(msg instanceof MapMessage)) return ;

		// Player touched a item
		MapMessage message = (MapMessage)msg;
		
		if(server) {
			
		}else{
			int mapIndex = MapList.getInstance().getIndexByName(message.getMapName());
        	if(mapIndex >= 0) {
        		//game.recreatePhysicsSpace();
        		//game.reset(mapIndex,false);
        		// Dont reset it right away, cause that might cause some weird issues
        		game.setMapChangeIndex(mapIndex);
        	}
		}
	}
}